package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {

        //Class cls = String.class;//获取String的类对象
        //获取类对象表示类的完全限定名
        //String name = cls.getName();
        //System.out.println(name);

        Scanner scanner = new Scanner(System.in);
        System.out.println("输入类名：");
        String className = scanner.nextLine();
        Class cls = Class.forName(className);
        //进获取类名
        String name = cls.getSimpleName();
        System.out.println(name);

        //Package 包对象
        String pname = cls.getPackage().getName();
        System.out.println("包名:"+pname);

        //Method 方法对象
        Method[] methods = cls.getMethods();
        for (Method method:methods){
            System.out.println(method.getName());
        }


    }
}
